<?php
if($strStyleSheet == TRUE){
	echo "<table class='Normal' border='0' align='left' width='100%'>";
}
     echo "
     <tr align='left'  class='Normal'>
         <td align='left' colspan='3'>
             <H2>Order Search Result</H2>
         </td>
     </tr>
";
//include (MODULE . "/screen/SearchOrderHeader");
//include (MODULE . "/action/qrySelectOrderHeader");
        //echo $strSQL;
if(!$myrow[0]==""){
     do {

			echo "
				<tr bgcolor='".switch_background($boBG)."' class='Normal'>
					<td colspan='3'>
						<table   width='735' cellpadding='0' cellspacing='0' border='0' class='Normal' align='left'>
							<tr align='left' class='Normal'>
						         <td align='left' colspan='6' valign='middle'>
						             <H2>Order ".$myrow[ID]."</H2>
						         </td>
						     </tr>
							 
							 <tr class='Normal'>
						         <td align='center'>
						             <b>Status</b>
						         </td>
								 <td  align='center'>
								 	<b>Ordered</b>
								 </td>
								 <td align='center'>
						             <b>Despatched</b>
						         </td>
								 <td  align='center'>";
								 
								 if($myrow[PaidDate]){
								 	echo "
								 		<a href='" . ScreenURL("Invoice",array('intOrderHeaderID'=>$myrow[0]) ) . "' target='_blank'>Invoice</a>
								 	";
								 }else{
								 	echo "
										<b>Invoice</b>
									";
								 }
echo "
								 </td>
								 <td align='center'>
						             <b>Paid</b>
						         </td>
								 <td  align='center'>
								 	<b>Carriage</b>
								 </td>
							</tr>
							
							<tr class='Normal'>
						         <td align='left'>
						             ".DisplayLookupValue("tblOrderStatus","OrderStatus",$myrow[OrderStatus])."
						         </td>
								 <td  align='center'>
								 	".ReformatFromMySqlDate($myrow[OrderDate])."
								 </td>
								 <td align='center'>
						             ";
									if (($myrow[ShippedDate] == '0000-00-00') && ($myrow[OrderStatus] != '1')){
										echo "<b>Awaiting Shipment</b>";
									}else{
										echo "<b>".ReformatFromMySqlDate($myrow[ShippedDate])."</b>";
									}
						echo "
						         </td>
								 <td  align='center'>
								 	".ReformatFromMySqlDate($myrow[InvoiceDate])."
								 </td>
								 <td align='center'>
						             ".ReformatFromMySqlDate($myrow[PaidDate])."
						         </td>
								 <td  align='right'>
								 	<b>".$myrow[Freight]."</b>
								 </td>
							</tr>";
							
								if($myrow[Courier]){
									echo "
									<tr class='Normal'>
									 	<td colspan = '6'>
											<a href=\"JavaScript: newWindow = openWin( '" . ScreenURL("DisplayCourier",array('intCourierID'=>$myrow[Courier])) . "', 'DisplayCourier', 'width=800,height=600,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1' ); newWindow.focus()\">
								             ".DisplayLookupValue("tblCourier","Courier",$myrow[Courier])."
								            </a>
										</td>
									</tr>";
								}
						
								
								
     							if($myrow[SalesChannel] != 1){
									echo "
									<tr class='Normal'>
										<td align='left'>
								             <b>Sales Channel</b>
								        </td>
										<td colspan='5' align='left'>
												".DisplayLookupValue("tblSalesChannel","SalesChannel",$myrow[SalesChannel])."<br/>
										</td>
									</tr>
									";
								}
								
     							if(EXTRA_ORDER_FIELD){
									echo "
									<tr class='Normal'>
										<td align='left'>
								             <b>".EXTRA_ORDER_FIELD."</b>
								        </td>
										<td colspan='5' align='left'>
												".$myrow["OtherInfo"]."<br/>
										</td>
									</tr>
									";
								}
echo "
			</table>
		</td>
	</tr>
     <tr bgcolor='".switch_background($boBG)."' class='Normal'>
         <td>
             <a href='" . ScreenURL("DisplayOrderHeader",array('intOrderHeaderID'=>$myrow[0]) ) . "' target='_blank'>
             <img src='./images".SITE_SUFFIX."/update.gif' border='0' alt='Update' align='middle'></a>
         </td>
		 <td>
			 <div align='left'>
				 <a href='".ScreenURL("DisplayCustomer",array('intCustomerID'=>$myrow[Customer]) )."' target='_blank'>".$myrow[ShipName]."</a><br/>
				 ".$myrow[ShipAddress]."<br/>";
				 	if($myrow[ShipAddress2]){
				 		echo $myrow[ShipAddress2]."<br/>";
					}
echo "
				 ".$myrow[ShipCity]."<br/>
				 ".$myrow[ShipRegion]."<br/>
				 ".$myrow[ShipPostalCode]."<br/>
				 ".$myrow[ShipCountry]."
			 </div>
         </td>
";
echo "
         <td align='right'>
              <a href=\"" . ScreenURL("SearchOrderHeader",array('intOrderHeaderID'=>$myrow[0],'ACTION'=>"qryDeleteOrder") ) . "\"
                 onclick=\"return confirmLink(this, 'Delete Order ".$myrow[0]."');\">
              <img src='./images".SITE_SUFFIX."/delete.gif' border='0' alt='Delete' align='middle'></a>
         </td>
";
echo "
     </tr>
     <tr>
         <td colspan='3'>
             <hr>
         </td>
     </tr>
";

         $boBG = -1 - $boBG;
     } while ($myrow = mysql_fetch_array($result));
}else{
echo "
     <tr class='MandatoryRed'>
         <td colspan='3'>
             Your Search Has Returned No Results.
         </td>
     </tr>
";
}
	if($strStyleSheet == TRUE){
   		echo "</table>";
	}
?>
